import request from '@/utils/request'
import getUserProfileName from "@/utils/getUserProfile"

// 查询订单支付列表
export function listOrder(query) {
  return request({
    url: '/station/order/list',
    method: 'get',
    params: query
  })
}

// 查询合伙人伙伴
export function getFirstAccount() {
  return request({
    url: '/system/user/cooperator'
  })
}

// 查询订单支付列表
export function listAllOrder(query) {
  return request({
    url: '/station/order/allList',
    method: 'get',
    params: query
  })
}

// 查询订单支付详细
export function getOrder(orderId) {
  return request({
    url: '/station/order/' + orderId,
    method: 'get'
  })
}
// 当前订单退款
export function refund(orderId) {
  return request({
    url: '/station/order/refund/' + orderId,
    method: 'get'
  })
}
// 恢复当前订单
export function reback(orderId) {
  return request({
    url: '/station/order/reback/' + orderId,
    method: 'get'
  })
}


// 新增订单支付
export function addOrder(data) {
  return request({
    url: '/station/order',
    method: 'post',
    data: data
  })
}

// 修改订单支付
export function updateOrder(data) {
  return request({
    url: '/station/order',
    method: 'put',
    data: data
  })
}

// 删除订单支付
export function delOrder(orderId) {
  return request({
    url: '/station/order/' + orderId,
    method: 'delete'
  })
}

// 导出订单支付
export function exportOrder(query) {
  return request({
    url: '/station/order/export',
    method: 'get',
    params: query
  })
}
/**
 * 补打标签
 */
export function printOrderInfo(query) {
  return request({
    url: '/station/order/feiePush',
    method: 'get',
    params: query
  })
}

// 导出lng集团订单
export function exportLngOrderGroup(query) {
  return request({
    url: '/station/order/LNGExport',
    method: 'get',
    params: query
  })
}

// 导出lng站点订单
export function exportLngOrderStation(query) {
  return request({
    url: '/station/order/LNGDeptExport',
    method: 'get',
    params: query
  })
}


// 查询站点订单
export function queryGroupOrder(query) {
  return request({
    url: '/station/order/LNGlist',
    method: 'get',
    params: query
  })
}


// 查询积分消费订单详细
export function queryStationOrder(query) {
  return request({
    url: '/station/order/LNGDeptList',
    method: 'get',
    params: query
  })
}

// 查询各油企总体数据
export function listEnterpriseData(query) {
  return request({
    url: '/station/order/selectStatisticsPayOrderList',
    method: 'get',
    params: query
  })
}


// 查询各油企总计金额
export function listEnterpriseDataSum(query) {
  return request({
    url: '/station/order/selectStatisticsPayOrderSum',
    method: 'get',
    params: query
  })
}


// 查询各油企总体数据
export function listEnterpriseDataExport(query) {
  return request({
    url: '/station/order/selectStatisticsPayOrderListExport',
    method: 'get',
    params: query
  })
}

// 查询订单支付列表
export function selectSumPayOrder(query) {
  return request({
    url: '/station/order/selectSumPayOrder',
    method: 'get',
    params: query
  })
}

// 查询按照油品的统计
export async function selectOilPayOrderSum(query) {

  // 判断是否的admin 账号，如果不是，传 isDelete = 0 到后端，如果是则不用传参
  const isDelete = await getUserProfileName()
  let queryPlass
  if (isDelete) {
    queryPlass = query
  } else {
    queryPlass = { ...query, isDeleted: 0 }
  }

  return request({
    url: '/station/order/selectOilPayOrderSum',
    method: 'get',
    params: queryPlass
  })
}


// 导出油品汇总信息
export function selectOilPayOrderSumExport(query) {
  return request({
    url: '/station/order/selectOilPayOrderSumExport',
    method: 'get',
    params: query
  })
}

// 删除今日订单
export function delOrderDeletePay(ids) {
  return request({
    url: '/station/order/deletePay',
    method: 'delete',
    data: ids
  })
}

// 删除班结
export function classSettlementDelete(ids) {
  return request({
    url: '/station/classSettlement/delete',
    method: 'delete',
    data: ids
  })
}

// 查询油企
export function enterpriseList(query) {
  return request({
    url: '/enterprise/info/list',
    method: 'get',
    params: query
  })
}


// 修改订单：修改一段时间内的订单金额(今日订单，历史订单)
export function updatePayOrderAmtApi(query) {
  return request({
    url: '/station/order/updatePayOrderAmt',
    method: 'get',
    params: query
  })
}

// 自动班结设置
export function setAutomaticClass(data) {
  return request({
    url: '/station/classSettlement/setAutomaticClass',
    method: 'post',
    data
  })
}

// 获取自动班结
export function getAutomaticClass(query) {
  return request({
    url: '/station/classSettlement/getAutomaticClass',
    method: 'get',
    params: query
  })
}

// 查询所有订单的金额
export function newSelectStatisticsPayOrderSum(query) {
  return request({
    url: '/station/order/newSelectStatisticsPayOrderSum',
    method: 'get',
    params: query
  })
}

// 查询所有已支付订单
export function newSelectStatisticsPayOrderList(query) {
  return request({
    url: '/station/order/newSelectStatisticsPayOrderList',
    method: 'get',
    params: query
  })
}

// 油企订单数据导出
export function newSelectStatisticsPayOrderListExport(query) {
  return request({
    url: '/station/order/newSelectStatisticsPayOrderListExport',
    method: 'get',
    params: query
  })
}

// 班次设置
export function updateClassTime(query) {
  return request({
    url: '/station/classSettlement/updateClassTime',
    method: 'post',
    data: query
  })
}

//根据查询班次时间
export function getDayClassTime() {
  return request({
    url: '/station/classSettlement/getDayClassTime',
    method: 'get',
  })
}

// 根据账号权限查询油枪
export function getGunList() {
  return request({
    url: '/stationOillGun/info/order/oilGun',
    method: 'get',
  })
}
// 新增自定义订单字段
export function addOrderFields(data) {
  return request({
    url: "/customListColumn/addListColumn",
    method: "post",
    data: data,
  });
}
// 获取自定义字段
export function getOrderFields(query) {
  return request({
    url: '/customListColumn/selectListColumn',
    method: 'get',
    params: query
  })
}
// 获取自定义支付方式
export function getPayTypeListApi(query) {
  return request({
    url: '/order/payType/query',
    method: 'get',
    params: query
  })
}
//订单详情
export function getOrderDetailsApi(query) {
  return request({
    url: '/station/historyOrder/getInfo',
    method: 'get',
    params: query
  })
}

// 查询单个油企信息
export function getEnterpriseInfoGetone(data) {
  return request({
    url: '/enterprise/info/getOne',
    method: 'post',
    data
  })
}

export function getEngineExport(data) {
  return request({
    url: '/engine/export',
    method: 'post',
    data
  })
}